Back to course home
0% completed
Vote For New Content
Oracle Hard
Integer to English Words (hard)
Solution: Integer to English Words
Trapping Rain Water (hard)
Solution: Trapping Rain Water
First Missing Positive (hard)
Solution: First Missing Positive
Merge K Sorted Lists (hard)
Solution: Merge K Sorted Lists
Max Points on a Line (hard)
Solution: Max Points on a Line
Sudoku Solver (hard)
Solution: Sudoku Solver
Longest Valid Parentheses (hard)
Solution: Longest Valid Parentheses
Remove Nth Node From End of List (Medium)
Solution: Remove Nth Node From End of List
Median of Two Sorted Arrays (hard)
Solution: Median of Two Sorted Arrays
Constrained Subsequence Sum (hard)
Solution: Constrained Subsequence Sum
Basic Calculator II (medium)
Problem Statement
Given a string s, representing the mathematical expression, evaluate the expression and return the integer value.
The integer division should truncate toward zero.
*Note: You are not allowed to use the built-in functions like eval().
Examples
Example 1:
- Input:
"8*5/4+3-2" - Expected Output:
11 - Justification: The calculation proceeds as follows:
8*5 = 40,40/4 = 10,10+3 = 13,13-2 = 11.
Example 2:
- Input:
"10+20/5*3" - Expected Output:
22 - Justification: The order of operations gives
20/5 = 4,4*3 = 12, and10+12 = 22.
Example 3:
- Input:
"50-25+5*3/2*2-10/2" - Expected Output:
34 - Justification: Following the order of operations:
50 - 25 = 25,(15/2) = 7(rounded down),7*2 = 14,25+14 = 39,10/2 = 5, and39 - 5 = 34.
Try it yourself
Try solving this question here:
Java
. . . .
Solution: Next Permutation
Solution: Basic Calculator II
Mark as Completed
On this page
Problem Statement
Examples
Try it yourself